<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
	<xsl:output method="html" />

	<!-- Document root -->
	<xsl:template match="/w:document">
		<xsl:apply-templates select="w:body" />
	</xsl:template>

	<!-- Body and paragraphs -->
	<xsl:template match="w:body">
		<html>
			<body>
				<xsl:for-each select="w:p">
					<p>
						<xsl:apply-templates select="w:pPr" />
						<xsl:apply-templates select="w:r" />
					</p>
				</xsl:for-each>
			</body>
		</html>
	</xsl:template>

	<!--  Paragraph properties -->
	<xsl:template match="w:pPr">
		<xsl:attribute name="style">
			<xsl:apply-templates />
		</xsl:attribute>
	</xsl:template>

	<!-- Text alignment -->
	<xsl:template match="w:jc">
		text-align:
		<xsl:value-of select="@w:val" />
	</xsl:template>

	<!-- Run -->
	<xsl:template match="w:r">
		<span>
			<xsl:apply-templates select="w:rPr" />
			<xsl:value-of select="w:t" />
		</span>
	</xsl:template>

	<!-- Run properties -->
	<xsl:template match="w:rPr">
		<xsl:attribute name="style">
			<xsl:apply-templates />
		</xsl:attribute>
	</xsl:template>

	<!--  Font size -->
	<xsl:template match="w:sz">
		font-size:
		<xsl:value-of select="@w:val" />
		px;
	</xsl:template>
	
	<!-- Vertical alignment -->
	<xsl:template match="w:vertAlign">
		<xsl:variable name="jcVal" select="@w:val" />
		<xsl:if test="$jcVal = 'superscript'">
			font-size:33%;position:relative;bottom:0.5em;
		</xsl:if>
		<xsl:if test="$jcVal = 'subscript'">
			font-size:33%;position:relative;bottom:-0.5em;
		</xsl:if>
	</xsl:template>

	<!-- Bold -->
	<xsl:template match="w:b">font-weight:bold;</xsl:template>

	<!-- Italic -->
	<xsl:template match="w:i">font-style:italic;</xsl:template>

	<!-- Underline -->
	<xsl:template match="w:u">text-decoration:underline;</xsl:template>

</xsl:stylesheet>
